package com.wrupple.muba.catalogs.client.activity.impl;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.Image;
import com.wrupple.muba.catalogs.client.activity.CatalogActivity;
import com.wrupple.muba.catalogs.client.module.services.presentation.CatalogPlaceInterpret;
import com.wrupple.muba.common.client.activity.AbstractSequentialActivity;
import com.wrupple.muba.common.domain.DesktopPlace;
import com.wrupple.muba.common.shared.State.DesktopManager;
import com.wrupple.muba.common.shared.State.ProcessManager;

public abstract class AbstractCatalogActivity<T extends ProcessManager> extends AbstractSequentialActivity<T> implements
		CatalogActivity {

	
	protected CatalogPlaceInterpret interpret;
	
	protected String catalog;

	protected String entryId;

	protected EventBus eventBus;
	
	public AbstractCatalogActivity(T pm,CatalogPlaceInterpret placeInterpret,DesktopManager dm) {
		super(pm, dm);
		this.interpret = placeInterpret;
	}

	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		DesktopPlace place = dm.getWhere();
		this.eventBus = eventBus;
		this.catalog = interpret.getPlaceCatalog(place);
		this.entryId = interpret.getCurrentPlaceEntry(place);
		super.start(panel, eventBus);
	}

	protected Image generateButton(ImageResource resource, ClickHandler handler) {
		Image regreso = new Image(resource);
		regreso.addClickHandler(handler);
		return regreso;
	}

}
